Skip to content

feat: support JSON5 task files alongside YAML#233

Merged
josegonzalez merged 2 commits intomainfrom
218-add-support-for-specifying-a-task-json-file
Apr 29, 2026
Merged

feat: support JSON5 task files alongside YAML#233
josegonzalez merged 2 commits intomainfrom
218-add-support-for-specifying-a-task-json-file

Conversation

@josegonzalez
Copy link
Copy Markdown
Member

Summary

Task files may now be authored in JSON5, with format selected by the file extension (.yml / .yaml for YAML, .json / .json5 for JSON5). When --tasks is omitted, docket probes tasks.yml, tasks.yaml, then tasks.json in source order. JSON5 is a strict superset of JSON so existing JSON files parse unchanged; the JSON5 extras (// and /* */ comments, trailing commas, unquoted keys) make hand-authored recipes more comfortable.

apply, plan, validate, init, and fmt all accept either format. init infers the surface from the --output extension. fmt round-trips JSON5 comments via an in-tree comment-aware AST so the canonical layout is identical between the YAML and JSON5 surfaces.

Closes #218.

Task files may now be authored in JSON5, with format selected by the
file extension (`.yml` / `.yaml` for YAML, `.json` / `.json5` for
JSON5). When `--tasks` is omitted, docket probes `tasks.yml`,
`tasks.yaml`, then `tasks.json` in source order. JSON5 is a strict
superset of JSON so existing JSON files parse unchanged; the JSON5
extras (`//` and `/* */` comments, trailing commas, unquoted keys)
make hand-authored recipes more comfortable. `apply`, `plan`,
`validate`, `init`, and `fmt` all accept either format. `init` infers
the surface from the `--output` extension, and `fmt` round-trips
JSON5 comments via an in-tree comment-aware AST so the canonical
layout is identical between the YAML and JSON5 surfaces.
@dokku-bot
Copy link
Copy Markdown

sh-checker report

To get the full details, please check in the job output.

shellcheck errors
shellcheck checking is disabled.
shfmt errors

'shfmt -l -d -i 2' returned error 1 finding the following formatting issues:

----------
tests/bats/task_file_json.bats
diff tests/bats/task_file_json.bats.orig tests/bats/task_file_json.bats
--- tests/bats/task_file_json.bats.orig
+++ tests/bats/task_file_json.bats
@@ -70,7 +70,7 @@
 
 @test "docket auto-detects tasks.json when no --tasks flag is given" {
   cd "$BATS_TEST_TMPDIR"
-  cat > tasks.json <<'EOF'
+  cat >tasks.json <<'EOF'
 [
   {
     tasks: [
@@ -87,7 +87,7 @@
 
 @test "docket prefers tasks.yml over tasks.json when both exist" {
   cd "$BATS_TEST_TMPDIR"
-  cat > tasks.yml <<'EOF'
+  cat >tasks.yml <<'EOF'
 ---
 - tasks:
     - name: yaml-task
@@ -94,7 +94,7 @@
       dokku_app:
         app: api
 EOF
-  cat > tasks.json <<'EOF'
+  cat >tasks.json <<'EOF'
 [
   { tasks: [{ name: "json-task", dokku_app: { app: "api" } }] },
 ]
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt -l -d -i 2 -w filename


Drop the redundant whitespace after `>` in cat-to-heredoc redirects in
the new task_file_json.bats so shfmt's `-i 2` rules pass, remove the
unused `local lib` declaration left over from the BATS_LIB_PATH
refactor in test_helper.bash, and widen the shellcheck disable
directive to cover SC1091 alongside SC1090 on the dynamic source
paths.
@josegonzalez josegonzalez merged commit e3f9a12 into main Apr 29, 2026
10 checks passed
@josegonzalez josegonzalez deleted the 218-add-support-for-specifying-a-task-json-file branch April 29, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for specifying a task.json file

2 participants